<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: Using Creative Senz3D and other Intel RealSense SDK compatible depth sensors</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="../../d9/df8/tutorial_root.html">OpenCV Tutorials</a></li><li class="navelem"><a class="el" href="../../de/d3d/tutorial_table_of_content_app.html">Application utils (highgui, imgcodecs, videoio modules)</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Using Creative Senz3D and other Intel RealSense SDK compatible depth sensors </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><b>Prev Tutorial:</b> <a class="el" href="../../d4/d65/tutorial_orbbec_astra.html">Using Orbbec Astra 3D cameras</a></p>
<p><b>Note</b>: This tutorial is partially obsolete since PerC SDK has been replaced with RealSense SDK</p>
<p>Depth sensors compatible with Intel® RealSense SDK are supported through VideoCapture class. Depth map, RGB image and some other formats of output can be retrieved by using familiar interface of VideoCapture.</p>
<p>In order to use depth sensor with OpenCV you should do the following preliminary steps:</p>
<ol type="1">
<li>Install Intel RealSense SDK 2.0 (from here <a href="https://github.com/IntelRealSense/librealsense">https://github.com/IntelRealSense/librealsense</a>).</li>
<li>Configure OpenCV with Intel RealSense SDK support by setting WITH_LIBREALSENSE flag in CMake. If Intel RealSense SDK is found in install folders OpenCV will be built with Intel Realsense SDK library (see a status LIBREALSENSE in CMake log).</li>
<li>Build OpenCV.</li>
</ol>
<p>VideoCapture can retrieve the following data:</p>
<ol type="1">
<li>data given from depth generator:<ul>
<li>CAP_INTELPERC_DEPTH_MAP - each pixel is a 16-bit integer. The value indicates the distance from an object to the camera's XY plane or the Cartesian depth. (CV_16UC1)</li>
<li>CAP_INTELPERC_UVDEPTH_MAP - each pixel contains two 32-bit floating point values in the range of 0-1, representing the mapping of depth coordinates to the color coordinates. (CV_32FC2)</li>
<li>CAP_INTELPERC_IR_MAP - each pixel is a 16-bit integer. The value indicates the intensity of the reflected laser beam. (CV_16UC1)</li>
</ul>
</li>
<li>data given from RGB image generator:<ul>
<li>CAP_INTELPERC_IMAGE - color image. (CV_8UC3)</li>
</ul>
</li>
</ol>
<p>In order to get depth map from depth sensor use VideoCapture::operator &gt;&gt;, e. g. : </p><div class="fragment"><div class="line">VideoCapture capture( <a class="code" href="../../d4/d15/group__videoio__flags__base.html#gga023786be1ee68a9105bf2e48c700294da7f442efc12cf9056cf4dc1597ba7fda6">CAP_REALSENSE</a> );</div><div class="line"><span class="keywordflow">for</span>(;;)</div><div class="line">{</div><div class="line">    Mat depthMap;</div><div class="line">    capture &gt;&gt; depthMap;</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span>( <a class="code" href="../../d7/dfc/group__highgui.html#ga5628525ad33f52eab17feebcfba38bd7">waitKey</a>( 30 ) &gt;= 0 )</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">}</div></div><!-- fragment --><p> For getting several data maps use VideoCapture::grab and VideoCapture::retrieve, e.g. : </p><div class="fragment"><div class="line">VideoCapture capture(<a class="code" href="../../d4/d15/group__videoio__flags__base.html#gga023786be1ee68a9105bf2e48c700294da7f442efc12cf9056cf4dc1597ba7fda6">CAP_REALSENSE</a>);</div><div class="line"><span class="keywordflow">for</span>(;;)</div><div class="line">{</div><div class="line">    Mat depthMap;</div><div class="line">    Mat image;</div><div class="line">    Mat irImage;</div><div class="line"></div><div class="line">    capture.grab();</div><div class="line"></div><div class="line">    capture.retrieve( depthMap, <a class="code" href="../../dc/dfc/group__videoio__flags__others.html#ggad354fdd0fcc8202f7624903c065bef06a0633813010b6c21838951de5fb34d643">CAP_INTELPERC_DEPTH_MAP</a> );</div><div class="line">    capture.retrieve(    image, <a class="code" href="../../dc/dfc/group__videoio__flags__others.html#ggad354fdd0fcc8202f7624903c065bef06a5c722445f6d9324474cf50b39b92ae74">CAP_INTELPERC_IMAGE</a> );</div><div class="line">    capture.retrieve(  irImage, <a class="code" href="../../dc/dfc/group__videoio__flags__others.html#ggad354fdd0fcc8202f7624903c065bef06a56fd50220f952776712bcfb656a5c64d">CAP_INTELPERC_IR_MAP</a>);</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span>( <a class="code" href="../../d7/dfc/group__highgui.html#ga5628525ad33f52eab17feebcfba38bd7">waitKey</a>( 30 ) &gt;= 0 )</div><div class="line">        <span class="keywordflow">break</span>;</div><div class="line">}</div></div><!-- fragment --><p> For setting and getting some property of sensor` data generators use VideoCapture::set and VideoCapture::get methods respectively, e.g. : </p><div class="fragment"><div class="line">VideoCapture capture(<a class="code" href="../../d4/d15/group__videoio__flags__base.html#gga023786be1ee68a9105bf2e48c700294da7f442efc12cf9056cf4dc1597ba7fda6">CAP_REALSENSE</a>);</div><div class="line">capture.set( <a class="code" href="../../dc/dfc/group__videoio__flags__others.html#gga6ff34ec31356df0b3cef388a831bf4daaf09153f3c7f98ceb038d39453da205cf">CAP_INTELPERC_DEPTH_GENERATOR</a> | <a class="code" href="../../dc/dfc/group__videoio__flags__others.html#ggaa54b7c54ed4ccfdb606549a42d3553b9a03489c9c3fc5b2656a9063f2e079d7a3">CAP_PROP_INTELPERC_PROFILE_IDX</a>, 0 );</div><div class="line">cout &lt;&lt; <span class="stringliteral">&quot;FPS    &quot;</span> &lt;&lt; capture.get( <a class="code" href="../../dc/dfc/group__videoio__flags__others.html#gga6ff34ec31356df0b3cef388a831bf4daaf09153f3c7f98ceb038d39453da205cf">CAP_INTELPERC_DEPTH_GENERATOR</a>+<a class="code" href="../../d4/d15/group__videoio__flags__base.html#ggaeb8dd9c89c10a5c63c139bf7c4f5704daf01bc92359d2abc9e6eeb5cbe36d9af2">CAP_PROP_FPS</a> ) &lt;&lt; endl;</div></div><!-- fragment --><p> Since two types of sensor's data generators are supported (image generator and depth generator), there are two flags that should be used to set/get property of the needed generator:</p>
<ul>
<li>CAP_INTELPERC_IMAGE_GENERATOR &ndash; a flag for access to the image generator properties.</li>
<li>CAP_INTELPERC_DEPTH_GENERATOR &ndash; a flag for access to the depth generator properties. This flag value is assumed by default if neither of the two possible values of the property is set.</li>
</ul>
<p>For more information please refer to the example of usage <a href="https://github.com/opencv/opencv/tree/master/samples/cpp/videocapture_intelperc.cpp">videocapture_intelperc.cpp</a> in opencv/samples/cpp folder. </p>
</div></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:34 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
